home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / utilit~1 / lack.zoo / lack.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-27  |  6.5 KB  |  179 lines

  1. #include <basepage.h>
  2. #include "gemlib/gemfast.h"
  3. #include "gemlib/aesbind.h"
  4. #include "lackfs.h"
  5. #include "filesys.h"
  6. #undef gem /* Why the hell is this defined anyway?  And why is it being
  7.             * even in strings? */
  8.  
  9. #define M_CORE        0x01    /* region came from core map */
  10. #define M_ALT        0x02    /* region came from alt map */
  11. #define M_NEWPROT    0x08    /* change mem protection of existing region */
  12. #define    M_PROTMODE    0xf0        /* protection mode bits */
  13. #define M_PROT_P    0x00        /* no read or write */
  14. #define M_PROT_G    0x10        /* any access OK */
  15. #define M_PROT_S    0x20        /* any super access OK */
  16. #define M_PROT_PR    0x30        /* any read OK, no write */
  17. #define M_PROT_I    0x40        /* invalid page */
  18. #define M_KEEP        0x0100    /* don't free on process termination */
  19.  
  20. /* oy, all this stuff needs to be included for the damn lap structure to
  21.  * be declared
  22.  */
  23.  
  24. /* a FEW structers: */
  25.  
  26. /* Oh boy, an undocumented aes feature! */
  27. struct appl
  28. {
  29.     struct appl *next;
  30.     long junk;    /* I have no idea */
  31.     struct save_area *save_area; /* see trap2.c */
  32.     char name[8];    /* not null terminated, filled with spaces */
  33.     long junk2[2];  /* I know the rsc and menu pointers are in
  34.              * here somewhere, maybe here -- no.
  35.              */
  36.     int apid;     /* at offset 1c */
  37. };
  38.  
  39. #define evnt_que ((struct appl * volatile * volatile)0xa78e)
  40. #define run_que  ((struct appl * volatile * volatile)0xa792)
  41. /* I don't know why both these volatiles are nessicary, but they seem to be. */
  42. /* How can the constant 0xa792 be volatile anyway? */
  43. #define cur_apid ((*(run_que))->apid)
  44. #define aes_appl (*(run_que))
  45. #define appl_waiting ((char *)0xa81e)
  46.  
  47. #define NUM_APPS 8
  48.  
  49. #define NULL (void *)0
  50. #define TRUE 1
  51. #define FALSE 0
  52.  
  53.  
  54. struct lacc
  55. {
  56.     int free;
  57.     int pid;
  58.     OBJECT *menu;    /* let's not deal with that quite yet */
  59.     BASEPAGE *base;
  60.     AESP *old_call;
  61.     int menu_index;
  62.     char menu_title[23];
  63.     char name[9];
  64.     char myname[9];
  65.     int isprg;
  66. };
  67.  
  68. typedef struct lapplication
  69. {
  70.     long istk, mystk; /* interupt stack pointer, lack's ssp */
  71.     long regs[13]; /* d1-d7/a2-a7 d1 contains sr */
  72.     long jmppc;
  73.     long jmpusp;
  74.     long mystk_base; /* the start of lack's stack */
  75.     unsigned long mask; /* signals returned by sigblock */
  76.     AESP *call;
  77.     struct lacc *acc;
  78.     int update;
  79.     struct wind *windows; /* see wind.c */
  80.     void (*pc)();     /* This is sort of fucked.  When the desktop is
  81.                * active, or lack has just started up, this is
  82.                * the value of the pc we intercepted from gem's
  83.                * internal variables, otherwise, this is a pointer
  84.                * to the pc on the initial trap 2 exeception, and
  85.                * is used in unload_acc().
  86.                */
  87.     int in_aes;       /* # of trap 2 calls it has to return from */
  88.     int action;
  89. }lap;
  90.  
  91. struct global_action
  92. {
  93.     int type;
  94.     int apid;
  95.     struct global_action *next;
  96. };
  97.  
  98. #define GL_SEND_KILL   1  /* send apid a message to coaxe it out of evnt_multi
  99.                             * and let parent eliminate it */
  100.  
  101. /* apid specific actions, and  aes commands */
  102. /* For aes commands actions are executed after leaving the aes, those
  103.  * commands with no action are handled before (or rather than) entering the
  104.  * aes.
  105.  */
  106. #define APPL_ALIVE       1  /* apid 0 makes a call after AC_CLOSE */
  107. #define APPL_KILL        2  /* kill this acc.  As an aes command:  this acc has
  108.                  * been effectively killed, the aes call in progress
  109.                  * should return immediately.  (The return pc has
  110.                  * been altered).
  111.                  */
  112. #define APPL_INIT       10  /* upgrade gl_version to 1.04, gl_apcount to 8. */
  113. #define APPL_YIELD      17  /* 0xf084 */
  114. #define APPL_EXIT       19  /* may exit to desktop, ignored if not apid 0. */
  115. #define MENU_BAR        30  /* No action, ignored if not apid 0. */
  116. #define MENU_REGISTER   35  /* No action, arg copied over old menu item.   */
  117. #define MENU_UNREGISTER 36  /* No action, menu item says "  name <blank>:. */
  118. #define WIND_CREATE    100  /* Save window handle for wind_new emulation.  */
  119. #define WIND_OPEN      101  /*  " */
  120. #define WIND_CLOSE     102  /*  " */
  121. #define WIND_DELETE    103  /* No action, window handle removed before aes call
  122.                  * goes through.
  123.                  */
  124. #define WIND_UPDATE    107  /* adjust curapp->update for wind_new emulation */
  125. #define WIND_NEW       109  /* No action, makes wind_delete calls then returns
  126.                  * to user.
  127.                  */
  128. #define RSRC_LOAD      110
  129. #define RSRC_FREE      111
  130. #define SHEL_FIND      124
  131. #define SHEL_ENVRN     125
  132.  
  133. /* here is how I declare the kernal funcs, not only does it provide prototypes
  134.  * but it saves a wopping four or eight clock cycles on each call
  135.  */
  136. #define ki       extern const struct kerinfo *const kernal
  137. /* let me try to cast these damn _LongFuncs
  138. #define kmshrink void(*m_shrink)(short, void *, long)=kernal->dos_tab[0x4a]
  139. #define kpexec   long(*p_exec)(short, char *, void *, void *)=kernal->dos_tab[0x4b]
  140. #define ksyield  void(*s_yield)(void)=kernal->dos_tab[0xff]
  141. #define kpgetpid int (*p_getpid)(void)=kernal->dos_tab[0x10b]
  142. #define kpdomain int (*p_domain)(int)=kernal->dos_tab[0x119]
  143. */
  144. #define kMalloc  void *(*m_alloc)(long size)=(void *(*)())kernal->dos_tab[0x48]
  145. #define kmshrink void(*m_shrink)(short, void *, long)=(void (*)())kernal->dos_tab[0x4a]
  146. #define kpexec   long(*p_exec)(short, char *, void *, void *)=(long (*)())kernal->dos_tab[0x4b]
  147. #define ksyield  void(*s_yield)(void)=(void (*)())kernal->dos_tab[0xff]
  148. #define kpwait   long(*p_wait)(void)=(long(*)())kernal->dos_tab[0x109]
  149. #define kpgetpid int (*p_getpid)(void)=(int (*)())kernal->dos_tab[0x10b]
  150. #define kpsigblock long (*p_sigblock)(long)=(long (*)())kernal->dos_tab[0x116]
  151. #define kpsigsetmask long (*p_sigsetmask)(long)=(long (*)())kernal->dos_tab[0x117]
  152. #define kpdomain int (*p_domain)(int)=(int (*)())kernal->dos_tab[0x119]
  153. #define kpmsg    long (*p_msg)(short, long, struct msg *)=(long (*)())kernal->dos_tab[0x125]
  154. #define kprenice int (*p_renice)(int, int)=(int (*)())kernal->dos_tab[0x127]
  155. #define ktgettime int (*t_gettime)(void)=(int (*)())kernal->dos_tab[0x2c]
  156. #define ktgetdate int (*t_getdate)(void)=(int (*)())kernal->dos_tab[0x2a]
  157. #define TRACE    kernal->trace
  158. #define DEBUG    kernal->debug
  159. #define ALERT    kernal->alert
  160. #define kmalloc  kernal->kmalloc
  161. #define kfree    kernal->kfree
  162. #define sleep    kernal->sleep
  163. #define wake     kernal->wake
  164. #define ksprintf kernal->sprintf
  165. #define IO_Q     3
  166. #define spl7() \
  167. ({\
  168.     short retval;\
  169. \
  170.     asm("    movw sr, %0;  \
  171.         oriw #0x700, sr" \
  172.         :"=d"(retval));\
  173.     retval;\
  174. })    
  175. #define spl(sr) \
  176. ({\
  177.     asm("    movw %0,sr"::"d"(sr));\
  178. })
  179.